<?php
/**
 * Created by PhpStorm.
 * User: Kevin
 * Date: 2018/8/28
 * Time: 17:10
 */
namespace app\admin\model;
use think\Db;
use think\Model;
class BusinessModel extends Model
{
    protected $name = "shops";


    public function getBusinessData($map,$Nowpage, $limits){
        return $this->where($map)
            ->field('s_id,s_name,s_pinlei,s_thumb,s_phone,s_address,s_status,s_money,s_score,s_close,s_open,s_image,s_admin,s_integral')
            ->page($Nowpage,$limits)
            ->select();
    }

    public function getAllCount($map){
        return $this->where($map)->count();
    }

    public function getActiveData($map,$Nowpage, $limits){
        return Db::name('shop_active')
            ->where($map)
            ->field('sa_id,sa_start,sa_end,sa_rule,sa_rule_con')
            ->page($Nowpage,$limits)
            ->order('sa_start desc')
            ->select();
    }

    public function getActiveCount($map){
        return Db::name('shop_active')->where($map)->count();
    }

    public function getAdvertiseData($map,$Nowpage, $limits){
        return Db::name('shop_advert')
            ->where($map)
            ->field('adv_id,adv_image,adv_title,adv_desc')
            ->page($Nowpage,$limits)
            ->select();
    }

    public function getAdvertiseCount($map){
        return Db::name('shop_advert')->where($map)->count();
    }

    public function getTypeData($map,$Nowpage, $limits){
        return Db::name('shop_type')
            ->where($map)
            ->field('st_id,st_name,st_order,st_thumb')
            ->page($Nowpage,$limits)
            ->order('st_order desc')
            ->select();
    }

    public function getTypeCount($map){
        return Db::name('shop_type')->where($map)->count();
    }
}